package com.znow.admin.system.security.model.dto;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;


/**
 * 系统用户DTO
 *
 * @author Nemo
 * @date 2022/09/29
 */
@Getter
@Setter
@ToString
@EqualsAndHashCode
public class SysUserDetailsDTO implements UserDetails {

    private static final long serialVersionUID = 1L;

    private Long userId;

    private String username;

    private String password;

    private String token;

    private List<PermissionsTreeDTO> authorities;

    public void setAuthorities(List<PermissionsTreeDTO> authorities) {
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
